#include <iostream>
#include <signal.h>
#include <cstring>
#include <unistd.h>

using namespace std;

void sigcb(int signo)
{
    cout << "get a signal, signal number: " << signo << endl;
}

int main()
{
    struct sigaction act, oact;
    memset(&act, 0, sizeof(act));
    memset(&oact, 0, sizeof(oact));
    
    act.sa_handler = sigcb;
    sigaction(2, &act, &oact);
    
    while(true)
    {
        cout << "I am a process, pid: " << getpid() << endl;
        sleep(1);
    }


    return 0;
}